package com.zzw.java.controller;

import com.zzw.java.pojo.DtuDTO;
import com.zzw.java.service.DtuService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.zzw.java.entity.LevelResult;
import org.springframework.web.bind.annotation.GetMapping;
import javax.annotation.Resource;
import java.util.List;

/**
 * DTU智能管理控制器
 *
 * @author XiaoJie
 * 2025/10/28 14:35
 */
@Controller
public class DtuController {

    @Resource
    private DtuService dtuService;

    /**
     * 跳转到DTU管理页面
     */
    @GetMapping("/")
    public String dtuIndex() {
        return "index";
    }

    /**
     * 重启DTU
     */
    @PostMapping("/dtu/restart")
    @ResponseBody
    public Boolean restartDtu() {
        return dtuService.restartDtu();
    }

    /**
     * 获取网络状态
     */
    @GetMapping("/dtu/networkStatus")
    @ResponseBody
    public String getNetworkStatus() {
        return dtuService.getNetworkStatus();
    }

    /**
     * 获取盒子数据列表
     */
    @PostMapping("/dtu/dataList")
    @ResponseBody
    public List<LevelResult> getDataList(@RequestBody DtuDTO dto) {
        return dtuService.queryLevelResults(dto);
    }

    /**
     * 获取DTU序列号
     */
    @GetMapping("/dtu/getSerialNumber")
    @ResponseBody
    public String getSerialNumber() {
        return dtuService.getSerialNumber();
    }

    /**
     * 获取DTU运行状态
     */
    @GetMapping("/dtu/getDtuRunStatus")
    public Object getDtuRunStatus() {
        return dtuService.getDtuRunStatus();
    }

    /**
     * 清空所有数据
     */
    @PostMapping("/dtu/removeAll")
    @ResponseBody
    public Boolean removeAll() {
        return dtuService.removeAll();
    }

    /**
     * dtu升级
     */
    @PostMapping("/dtu/upgrade")
    @ResponseBody
    public String upgrade() {
        return dtuService.upgrade();
    }

}
